<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateProjectCapacityReportMonthTable extends AbstractMigration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function up()
    {
        $this->table('project_capacity_report_month', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '产能每月上报表'])
            ->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '主键ID'])
            ->addColumn('project_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '项目id'])
            ->addColumn('tenant_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '租户id'])
            ->addColumn('step_category_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '分类id'])
            ->addColumn('number', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '产能数量'])
            ->addColumn('report_year', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '上报年'])
            ->addColumn('report_moth', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '上报月份'])
            ->addColumn('created', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '创建时间'])
            ->addColumn('created_by', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '创建人'])
            ->addColumn('updated', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '更新时间'])
            ->addColumn('updated_by', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '更新人'])

            ->addIndex(['project_id', 'step_category_id', 'report_moth'], ['type' => 'normal', 'name' => 'idx_report_month'])
            ->save();
    }

    public function down()
    {
        $this->table('library_view_config')->drop()->save();
    }

}
